package com.zyd.shiro.business.controller.pak;

import com.github.pagehelper.PageInfo;
import com.zyd.shiro.business.entity.Requisition;
import com.zyd.shiro.business.service.PakRequisitionService;
import com.zyd.shiro.framework.object.BaseConditionVO;
import com.zyd.shiro.framework.object.PageResult;
import com.zyd.shiro.framework.object.ResponseVO;
import com.zyd.shiro.util.ResultUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.zyd.shiro.persistence.beans.PakRequisition;
import io.swagger.annotations.ApiOperation;

import java.util.List;
import java.io.File;
import com.zyd.shiro.utils.FileUtils;
import com.zyd.shiro.utils.ExcelUtil;
import java.util.Date;


@RestController
@RequestMapping("/requisition")
@Api(description = "资产申请")
public class PakRequisitionController {
    @Autowired
    private PakRequisitionService requisitionService;

    @PostMapping
    @ApiOperation(value="添加", produces="application/json")
    public ResponseVO insert(Requisition requisition) {

        return ResultUtil.success("添加成功！",requisitionService.insert(requisition));
    }

    @PutMapping
    @ApiOperation(value="修改", produces="application/json")
    public ResponseVO update(Requisition requisition) {

        return ResultUtil.success("修改成功！", requisitionService.updateSelective(requisition));
    }

    @DeleteMapping(value = "/{id}")
    @ApiOperation(value="主键删除", produces="application/json")
    public ResponseVO delete(@PathVariable(name="id") Long id){
        requisitionService.removeByPrimaryKey(id);
        return ResultUtil.success("删除成功！",null);
    }

    @GetMapping
    @ApiOperation(value="分页查询", produces="application/json")
    public PageResult page(BaseConditionVO vo) {
        PageInfo<Requisition> pageInfo = requisitionService.findPageBreakByCondition(vo);
        return ResultUtil.tablePage(pageInfo);
    }

    @GetMapping(value = "/all")
    @ApiOperation(value="查询所有", produces="application/json")
    public ResponseVO list() {
        List<Requisition> requisitions = requisitionService.listAll();
        return ResultUtil.success("查询成功！",requisitions);
    }

}